package com.power.thread.concept;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo implements Callable {
    @Override
    public Integer call() {
        System.out.println(Thread.currentThread().getName());
        return 11;
    }
    public static void main(String[] args) {
        //创建线程
        FutureTask futureTask = new FutureTask(new CallableDemo());
        Thread thread = new Thread(futureTask);
        thread.start();
        try {
            //任务返回的结果
            System.out.println(futureTask.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
